"""A dictonary of all the classes of objects that can be found in flat lines.
the keys are the class types (names). The values describe each class:
 * The key list describes all the tags that must appear in a flat line
   in order for an object of the class to be said to be in the line.
   The object is uniquely identified by the values these tags receive
   in the flat line. The keys are also properties of the object.
 * In a key each tag receives one value (as appose to other properties that can
   have multiple values.) If multiple key values appear in a single flat line
   the different objects of the same class that are identified by the different
   key value should be smushed togther (see pending patent US20080215619)
 * The mandatory and optional lists specify additional properties of the object.
   The values assigned to the properties are accumulated from all the lines
   in which an object appears. Its possible for multiple values to be defined
   in the same flat line. By default, only uniqiue values are taken, but if
   the + sign is prefixed to a property tag, all the accumulated values are
   summed togther.
 * In addition properties in the mandatory list must appear in every flat line
   in  which the object is said to be in. However, these properties are not used
   as part of the object's key. The mandatory list acts as a filter on the lines
   in which an object can appear.
"""
classes={
    'account':{
        'key':['ACCTID'],
        'mandatory':[],
        'optional':['accountGroup','CURDEF','aCCTTYPE','ACCTTYPE']},
    'asset':{
        'key':['UNIQUEID'],
        'mandatory':[],
        'optional':['SECNAME','TICKER','assetClass',
                    'FIASSETCLASS','ASSETCLASS','SECTYPE',
                    'STOCKTYPE', 'OPTTYPE', 'DEBTTYPE', 'MFTYPE', 'DTMAT']}, 
    'assetpercent':{
        'key':['UNIQUEID','ASSETCLASS'],
        'mandatory':['PERCENT'],
        'optional':[]}, 
    'position':{
        'key':['ACCTID','DTASOF','UNIQUEID'],
        'mandatory':['UNITS'],
        'optional':['UNITPRICE','MKTVAL','DTPRICEASOF']},
    'transaction':{
        'key':['FITID', 'DTTRADE'],
        'mandatory':['ACCTID'],
        'optional':['DTSETTLE', 'UNIQUEID','SECNAME',
                    'tran', 'TRNTYPE',
                    'units', 'UNITPRICE','CURRENCY',
                    'TOTAL', 'FEES', 'TAXES',
                    'mEMO']
        },
    'checking':{
        'key':['FITID','DTPOSTED'],
        'mandatory':['ACCTID'],
        'optional':['NAME','PAYEEID','TRNTYPE',
                    'TRNAMT', 'mEMO']
        },
    # the following are "statement" objects
    # the tags mKTVAL, mktval and moneymrkt can be computed by web server
    'groupdayasof':{
        'key':['accountGroup','dayasof'],
        'mandatory':[],
        'optional':['+mKTVAL']},
    'accountdtasof':{
        'key':['ACCTID','DTASOF'],
        'mandatory':[],
        'optional':['AVAILCASH','BALAMT','bALAMT','+mktval','+moneymrkt']},
}
